package com.github.ilioili.justdoit.util;

import android.os.Build;
import android.view.View;
import android.view.Window;

import com.github.ilioili.justdoit.R;

/**
 * Created by hantuo on 16/5/18.
 */
public class ToobarUtil {
    public static void setToobarBackgroundColor(Window window, int color){
        View toobar = window.findViewById(R.id.toolbar);
        if(null!=toobar) toobar.setBackgroundColor(color);
    }
    public static void setStatusBarBackgroundColor(Window window, int color){
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
            window.setStatusBarColor(color);
        }else{
            window.getDecorView().setBackgroundColor(color);
        }
    }

    public static void setWindowColor(Window window, int color){
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
            window.setStatusBarColor(color);
            window.getDecorView().setBackgroundColor(color);
        }else{
            window.getDecorView().setBackgroundColor(color);
        }
    }

    public static void setStatusBarAndToolbarColor(Window window, int color){

        View toobar = window.findViewById(R.id.toolbar);
        if(null!=toobar) toobar.setBackgroundColor(color);
        if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
            window.setStatusBarColor(color);
        }else{
            window.getDecorView().setBackgroundColor(color);
        }
    }
}
